<?php
namespace Components\SMS\First;

class Service {
	public function sendSMS($data) {
		switch($data['t']) {
			case 1:
				$msg = '【万福商城】尊敬的' . $data['account'] . '，您有一个进货订单' . $data['create_time'] . '已经匹配成功，请登录查看！';
				break;
			case 2:
				$msg = '【万福商城】尊敬的' . $data['account'] . '，您有一个销售订单' . $data['create_time'] . '已经匹配成功，请登录查看！';
				break;
			case 3:
				$msg = '【万福商城】尊敬的' . $data['account'] . '商户您的账户资金有变动，请登录确认！';
				break;
			case 4:
				$msg = '【万福商城】注册验证码' . $data['code'] . '，10分钟内有效，注册完成后请联系推荐人激活！祝您生意兴隆！';
				break;
		}

		$post_data = array();
		$post_data['account'] = iconv('GB2312', 'GB2312',"yizhangjin_shandong379@");
		$post_data['pswd'] = iconv('GB2312', 'GB2312',"shandong379@");
		$post_data['mobile'] = $data['mobile'];
		//$post_data['msg']=mb_convert_encoding("$msg",'UTF-8', 'GB2312'); 
		$post_data['msg']=$msg; 
		$post_data['needstatus'] ='true';
		$url='http://hy.qixinhl.com/msg/HttpSendSM?';
		$o='';
		foreach ($post_data as $k=>$v) {
		   $o.= "$k=".urlencode($v)."&";
		}
		$post_data=substr($o,0,-1);

		$ch = curl_init();
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_URL,$url);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		$result = curl_exec($ch);
		curl_close($ch);
		return $result;
	}
}
